<template>
  <div>
    <el-row>
      <el-col :span="20" :offset="2">
        <el-table
          ref="singleTable"
          :data="commUsers"
          highlight-current-row
          @current-change="handleCurrentChange">
          <el-table-column  >
            <template slot-scope="scope" style="vertical-align: center">
              {{scope.row.deliveryAddressPick.provinceName+
              scope.row.deliveryAddressPick.cityName+
              scope.row.deliveryAddressPick.region+
              scope.row.deliveryAddressPick.address
              }}
              <span v-if="scope.row.isCloseUpShop==1" style="color: red">店铺打烊中</span>
            </template>
          </el-table-column>
        </el-table>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="20" >
        <el-pagination
          @size-change="sizeChange"
          @current-change="pageChange"
          :current-page="pageno"
          :page-sizes="[5, 10, 15, 20]"
          :page-size="pagesize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
        >
        </el-pagination>
      </el-col>
    </el-row>
  </div>
</template>

<script>
  export default {
    name: "CommUserView",
    data() {
      return {
        user: {commercialState: 1},
        pageno: 1,
        pagesize: 5,
        total: 1,
        commUsers: []
      }
    },
    methods: {
      getData() {
        //获取所有的商户
        var params = {}
        params["pageno"]=this.pageno;
        params["pagesize"]=this.pagesize;
        Object.keys(this.user).forEach(item => {
          params[item]=this.user[item];
        });
        this.$axios.get("queryUsersByTypeId.action", {params: params})
          .then(res => {
            this.commUsers = res.data.records;
            this.total=res.data.total;
          })
          .catch(err => {
            this.$message.error(err)
          })
      },
      handleCurrentChange(val) {
        //确认提货地址
        if (val.isCloseUpShop==0){
          this.$parent.$parent.order.commId=val.id;
          this.$parent.$parent.addr.addrName=val.deliveryAddressPick.provinceName+
            val.deliveryAddressPick.cityName+
            val.deliveryAddressPick.region+
            val.deliveryAddressPick.address;
          this.$parent.$parent.addr.addrId=val.id;
          this.cancel();
        }else {
          this.$message.warning("店铺打烊中,请重新选择")
        }

      },
      cancel() {
        this.$parent.$parent.dialogVisible2 = false;
      },
      sizeChange(val) {
        //每页范围
        this.pagesize = val;
        this.getData();
      },
      pageChange(val) {
        //当前页
        this.pageno = val;
        this.getData();
      },
    }
  }
</script>

<style scoped>

</style>
